package com.mini.constant;


/**
 * <p>redis key</p>
 * <PRE>
 * <BR>    修改记录
 * <BR>-----------------------------------------------
 * <BR>    修改日期         修改人          修改内容
 * </PRE>
 * @author zl
 * @date Created in 2017/11/30 19:30
 * @version 1.0
 * @copyright: Copyright (c) founders
 */

public class RedisKeyConst {

    /**
     * redis中间前缀
     */
    public static final String REDIS_SPLIT_PRE = ":";
    /**
     * redis中间后缀
     */
    public static final String REDIS_SPLIT_SUFFIX = "_";


    /**
     * 获取redis的key
     * @param pre
     * @param argArray
     * @return
     */
    public static String getKeyArray(String pre,Object[] argArray){
        StringBuffer sb = new StringBuffer();
        sb.append("mini-data-es").append(REDIS_SPLIT_PRE).append(pre);
        if(argArray != null && argArray.length != 0) {
            int start = 0;
           for(int i=0;i< argArray.length;i++){
               if(argArray[i]==null){
                   continue;
               }
               if(start==0){
                   sb.append(REDIS_SPLIT_PRE);
               }else {
                   sb.append(REDIS_SPLIT_SUFFIX);
               }
               sb.append(argArray[i]);
               start ++;
           }
        }
        return sb.toString();
    }

    public static String getLockKey(Object[] objects) {
        return getKeyArray("Lock",objects);
    }


    private static final String OPREATION_LOCK = "opreation-lock";
    public static String getOpreationLock(Object... objects) {
        return getKeyArray(OPREATION_LOCK,objects) ;
    }

    public static String getBfReportLockKey() {
        return getLockKey(new Object[] {"bf"});
    }
    public static String getDescartesReportLockKey() {
        return getLockKey(new Object[] {"descartes"});
    }

    public static String getStaticsLockKey() {
        return getLockKey(new Object[] {"Statics"});
    }

    public static String getErrorAttendanceLockKey() {
        return getLockKey(new Object[] {"error-attendance"});
    }
    public static String getErrorBigOrderLockKey() {
        return getLockKey(new Object[] {"error-bigOrder"});
    }

    public static String getStaticStudentInfoAttachsLockKey() {
        return getLockKey(new Object[] {"StaticsStudentInfoAttach"});
    }

    public static String getDeptFullNameKey(Long deptId) {
        return getKeyArray("DeptFullName",new Object[] {deptId});
    }

    public static String getUserDeptFullNameKey(Long userId) {
        return getKeyArray("UserDeptFullName",new Object[] {userId});
    }

    public static String getDeptNameKey(Long deptId) {
        return getKeyArray("DeptName",new Object[] {deptId});
    }

    public static String getDeptVOKey(Long deptId){
        return getKeyArray("DeptVO",new Object[] {deptId});
    }

    public static String getUserDeptNameKey(Long userId) {
        return getKeyArray("UserDeptName",new Object[] {userId});
    }

    public static String getUserSimpleInfoKey(Long userId) {
        return getKeyArray("UserSimpleInfo",new Object[] {userId});
    }



}
